package com.hup.sokoban.view.mapDesigner;

import com.hup.sokoban.view.customView.MapLabel;
import com.hup.sokoban.view.customView.StepRecordPanel;
import com.hup.sokoban.view.customView.mapListView.MapListView;
import com.hup.utils.swing.customView.FileChooserPanel;
import com.hup.utils.swing.customView.HScrollPanel;
import com.hup.utils.swing.customView.ImageButton;

import javax.swing.*;
import java.awt.*;

/**
 * @author hugan
 * @date 2020/4/29
 */
public class MapDesignerForm {
    public JPanel root;

    //左侧工具类
    public JPanel pLeft;
    public MapListView mapListView;

    //中间画布
    public MapLabel mapLabel;
    public StepRecordPanel stepRecordPanel;

    //底部,关卡信息
    public JPanel pMapInfo;
    public JTextField txtMapName;
    public JTextArea txtDescription;
    public FileChooserPanel txtBackgroundImage;
    public JCheckBox cbLockBgScale;

    //底部工具栏
    public JCheckBox cbMapList;
    public JCheckBox cbMapInfo;
    public JButton btnNew;
    public JButton btnSave;

    //画布设计
    public MapElementPanel mapElementPanel;
    public MapBoundsPanel mapBoundsPanel;
    public ImageButton btnHelp;

    {
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
// DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer
     * >>> IMPORTANT!! <<<
     * DO NOT edit this method OR call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        root = new JPanel();
        root.setLayout(new GridBagLayout());
        root.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(0, 3, 3, 3), null));
        pLeft = new JPanel();
        pLeft.setLayout(new GridBagLayout());
        GridBagConstraints gbc;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(pLeft, gbc);
        mapListView = new MapListView();
        mapListView.setDesigner(true);
        mapListView.setOrderByName(false);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        pLeft.add(mapListView, gbc);
        pMapInfo = new JPanel();
        pMapInfo.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.BOTH;
        pLeft.add(pMapInfo, gbc);
        pMapInfo.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), null));
        final JLabel label1 = new JLabel();
        label1.setText("关卡名");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(label1, gbc);
        final JLabel label2 = new JLabel();
        label2.setText("描述");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(label2, gbc);
        txtMapName = new JTextField();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 1.0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(txtMapName, gbc);
        final JScrollPane scrollPane1 = new JScrollPane();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(scrollPane1, gbc);
        txtDescription = new JTextArea();
        txtDescription.setLineWrap(true);
        txtDescription.setRows(3);
        scrollPane1.setViewportView(txtDescription);
        final JLabel label3 = new JLabel();
        label3.setText("背景图");
        label3.setToolTipText("默认为内置图片");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(label3, gbc);
        cbLockBgScale = new JCheckBox();
        cbLockBgScale.setHorizontalTextPosition(2);
        cbLockBgScale.setSelected(true);
        cbLockBgScale.setText("锁定背景比例");
        cbLockBgScale.setToolTipText("使界面缩放时,地图元素和背景图的位置保持绝对一致/不错位");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 6;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(cbLockBgScale, gbc);
        final HScrollPanel hScrollPanel1 = new HScrollPanel();
        hScrollPanel1.setHorizontalScrollSize(new Dimension(36, 3));
        hScrollPanel1.setHorizontalScrollUnit(20);
        hScrollPanel1.setMaximumSize(new Dimension(187, 32767));
        hScrollPanel1.setPreferredSize(new Dimension(187, 30));
        hScrollPanel1.setVerticalScrollBarPolicy(21);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 5;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 3, 0, 0);
        pMapInfo.add(hScrollPanel1, gbc);
        txtBackgroundImage = new FileChooserPanel();
        txtBackgroundImage.setChooserBtnTxt("背景图");
        txtBackgroundImage.setLabel("");
        hScrollPanel1.setViewportView(txtBackgroundImage);
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(panel1, gbc);
        mapLabel = new MapLabel();
        mapLabel.setDesigner(true);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        panel1.add(mapLabel, gbc);
        stepRecordPanel = new StepRecordPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel1.add(stepRecordPanel, gbc);
        final HScrollPanel hScrollPanel2 = new HScrollPanel();
        hScrollPanel2.setHorizontalScrollSize(new Dimension(1, 3));
        hScrollPanel2.setHorizontalScrollUnit(50);
        hScrollPanel2.setVerticalScrollBarPolicy(21);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 2;
        gbc.fill = GridBagConstraints.BOTH;
        root.add(hScrollPanel2, gbc);
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new GridBagLayout());
        hScrollPanel2.setViewportView(panel2);
        final JPanel panel3 = new JPanel();
        panel3.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        panel2.add(panel3, gbc);
        cbMapList = new JCheckBox();
        cbMapList.setSelected(true);
        cbMapList.setText("关卡列表(X)");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        panel3.add(cbMapList, gbc);
        cbMapInfo = new JCheckBox();
        cbMapInfo.setText("关卡信息(C)");
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.anchor = GridBagConstraints.WEST;
        panel3.add(cbMapInfo, gbc);
        btnSave = new JButton();
        btnSave.setText("保存");
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        panel2.add(btnSave, gbc);
        mapElementPanel = new MapElementPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 3;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(0, 10, 0, 0);
        panel2.add(mapElementPanel.$$$getRootComponent$$$(), gbc);
        btnNew = new JButton();
        btnNew.setText("<html>新建<br>空白</html>");
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        panel2.add(btnNew, gbc);
        final JPanel spacer1 = new JPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 5;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        panel2.add(spacer1, gbc);
        mapBoundsPanel = new MapBoundsPanel();
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = 0;
        gbc.fill = GridBagConstraints.BOTH;
        panel2.add(mapBoundsPanel.$$$getRootComponent$$$(), gbc);
        btnHelp = new ImageButton();
        btnHelp.setIcon(new ImageIcon(getClass().getResource("/img/common/icon_help.gif")));
        btnHelp.setToolTipText("帮助");
        gbc = new GridBagConstraints();
        gbc.gridx = 6;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.SOUTH;
        panel2.add(btnHelp, gbc);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() { return root; }
}
